package com.fau.wm.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc  健康档案表
 * @author suny
 * @datetime 2014年10月24日,上午10:21:38
 */
@Entity
@Table(name = "medical_call_health_symptom")
public class MedicalCallHealthSymptom implements Serializable, JSONAware {

	private static final long serialVersionUID = 2616295773717691574L;
	

	private String id;					//健康档案症状表ID
	
	@Length(max = 32, message = "健康档案症状父Pid长度需要32")
	private String pid;					 //健康档案正装表父ID
	
	@NotBlank(message = "健康档案症状名称不能为空")
	@Length(max = 88, message = "健康档案症状父长度需要0到88")
	private String name;				 //症状名称
	
	@Length(max = 88, message = "健康档案症状描述长度需要0到88")
	private String descpt;				 //健康档案症状描述
	
	private Date createTime = new Date();//创建时间
	private Date updateTime = new Date();//更新时间
	
	@Length(max = 32, message = "健康档案症状用户长度需要32")
	private String userId;				 //操作用户Id
	
	private String hospitalId;			 //医院标识id
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	@Column(name = "pid", length = 32)
	public String getPid() {
		return pid;
	}
	
	public void setPid(String pid) {
		this.pid = pid;
	}
	
	@Column(name = "name", length = 255)
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_time")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "user_id", length = 32)
	public String getUserId() {
		return userId;
	}
	
	public void setUserId(String userId) {
		this.userId = userId;
	}
	
	@Column(name = "descpt", length = 255)
	public String getDescpt() {
		return descpt;
	}

	public void setDescpt(String descpt) {
		this.descpt = descpt;
	}
	
	@Column(name = "hospital_id",length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("pid", pid);
		obj.put("name", name);
		obj.put("descpt", descpt);
		obj.put("hospitalId", hospitalId);
		if(this.createTime != null){
			obj.put("createTime", DateFormatUtils.format(this.createTime,"yyyy-MM-dd HH:mm:ss"));
		}
		if(this.updateTime != null){
			obj.put("updateTime", DateFormatUtils.format(this.updateTime,"yyyy-MM-dd HH:mm:ss"));
		}
		obj.put("userId", userId);
		return obj.toString();
	}
}
